﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiCharacter
    {
        public string WinPercentage { get; private set; }
        public double AverageScore { get; private set; }
        public int CharacterId { get; private set; }
        public string Class { get; private set; }
        public int Currency { get; private set; }
        public double Damage { get; private set; }
        public DateTime FirstPlayed { get; private set; }
        public double Healing { get; private set; }
        public DateTime LastPlayed { get; private set; }
        public int MapInstanceCount { get; private set; }
        public int PlayerId { get; private set; }
        public string PlayerName { get; private set; }
        public int PvEMatches { get; private set; }
        public int PvEWins { get; private set; }
        public int PvPMatches { get; private set; }
        public int PvPWins { get; private set; }
        public int SpentPoints { get; private set; }
        public double TotalHours { get; private set; }
        public double TotalMinutes { get; private set; }
        public int XP { get; private set; }

        public ApiCharacter()
        {
        }

        public ApiCharacter(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "a:WinPercentage": WinPercentage = ApiXmlNode.GetValue(reader); break;
                        case "a:avg_score": AverageScore = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:character_id": CharacterId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:class": Class = ApiXmlNode.GetValue(reader); break;
                        case "a:currency_value": Currency = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:damage": Damage = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:firstplayed": FirstPlayed = DateTime.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:healing": Healing = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:lastplayed": LastPlayed = DateTime.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:map_instance_cnt": MapInstanceCount = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:player_id": PlayerId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:player_na": PlayerName = ApiXmlNode.GetValue(reader); break;
                        case "a:pve_matches": PvEMatches = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:pve_win_totals": PvEWins = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:pvp_matches": PvPMatches = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:pvp_win_totals": PvPWins = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:spent_points": SpentPoints = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:total_hours": TotalHours = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:total_minutes": TotalMinutes = double.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:xp_value": XP = int.Parse(ApiXmlNode.GetValue(reader)); break;
                    }
                }
            }
        }
    }
}
